var deptTreeObj = {};
$(function() {
	initDeptTree();
	$("#saveprofile").click(function() {
		if(null ==  $("#deptId").val()){
			alert("没有选择部门!");
			return;
			
		}
		var url = "admin/user/user!saveprofile";
		var ps = $("form").serialize();
		doSubmit(url,ps,function(){
		    createNotify("用户信息更新成功!");
		});
	});	
	
	
	
});

function initDeptTree(){
	 var setting = {
				async : {
					enable : true,
					url : "business/component!roomonly",
					autoParam : ["id=bean.id"],
					otherParam:{"dtypes[0]":"Manager","dtypes[1]":"Manufacture","dtypes[2]":"Room"}
	            },
				callback: {
				    //onAsyncSuccess: zTreeOnAsyncSuccess,
				    onClick:zTreeOnClickMain
				}
	 };
	 var root = {
		  	  name : "西安北方特种能源有限公司西安庆华公司",
				  open : true,
				  nocheck:true,
				  id:"root",
				  isParent:true
	  } ;
	  var zNodes = [
		     root                      
	      ];
	  deptTreeObj = $.fn.zTree.init($("#deptUserTree"), setting,zNodes);
	
	 //var nodes = deptTreeObj.getNodes();

	 //zTreeObj.expandNode(nodes[0]);	
	
}
function zTreeOnClickMain(event, treeId, treeNode) {
	$("#deptId").val(treeNode.id);
    $("#deptName").text(treeNode.name);    
    
}